<?php

require_once 'ConnectionManager.php';

 function encode($str, $percentage=PERCENTAGE){
 //rasgele olarak karakterleri CENS_CHAR'la değiştirir    
     for($i = 0; $i < strlen($str); $i++){
         if(rand(0, 100) < PERCENTAGE){
             $str[$i] = chr(CENS_CHAR);
         }
     }
     return $str;
}

function getEncodedById($id){
   $conn = new ConnectionManager();  
   $where_clause = " id = ".$id." ";   
   $sonuc = $conn->SelectSignleRow("mesajlar", $where_clause);
   
   return $sonuc["sansurlu"];
}
function getNameById($id){
   $conn = new ConnectionManager();  
   $where_clause = " id = ".$id." ";   
   $sonuc = $conn->SelectSignleRow("mesajlar", $where_clause);
   
   return $sonuc["name"];
}

function getDecodedById($id){
   $conn = new ConnectionManager();  
   $where_clause = " id = ".$id." ";   
   $sonuc = $conn->SelectSignleRow("mesajlar", $where_clause);
   
   return $sonuc["sansursuz"];
}

function AddMessage($name, $email, $message){
   $fields[0] = "sansursuz";
   $fields[1] = "sansurlu";
   $fields[2] = "name";
   $fields[3] = "email";

   $values[0] = $message;
   $values[1] = encode($message);
   $values[2] = $name;
   $values[3] = $email;
}

?>
